home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Rechen2.cpp < prev    next >
C/C++ Source or Header  |  1998-12-11  |  2KB  |  53 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Rechen2.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. TForm1 *Form1;
  10. double Zahl1, Zahl2, Ergebnis;
  11.  
  12. //---------------------------------------------------------------------------
  13. __fastcall TForm1::TForm1(TComponent* Owner)
  14.     : TForm(Owner)
  15. {
  16. }
  17. //---------------------------------------------------------------------------
  18. void __fastcall TForm1::Label3Click(TObject *Sender)
  19. {
  20.   randomize ();
  21.   Zahl1 = double (random (1000)) /10;
  22.   Zahl2 = double (random (1000)) /10;
  23.   Label1->Caption = String (Zahl1);
  24.   Label2->Caption = String (Zahl2);
  25.   Label3->Caption = "WΣhle die Rechenart!";
  26. }
  27. //---------------------------------------------------------------------------
  28.  
  29. void __fastcall TForm1::Button1Click(TObject *Sender)
  30. {
  31.   Ergebnis = Zahl1 + Zahl2;
  32.   Label3->Caption = "Ergebnis der Addition: " + String(Ergebnis);
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TForm1::Button2Click(TObject *Sender)
  36. {
  37.   Ergebnis = Zahl1 - Zahl2;
  38.   Label3->Caption = "Ergebnis der Subtraktion: " + String(Ergebnis);
  39. }
  40. //---------------------------------------------------------------------------
  41. void __fastcall TForm1::Button3Click(TObject *Sender)
  42. {
  43.   Ergebnis = Zahl1 * Zahl2;
  44.   Label3->Caption = "Ergebnis der Multiplikation: " + String(Ergebnis);
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::Button4Click(TObject *Sender)
  48. {
  49.   Ergebnis = Zahl1 / Zahl2;
  50.   Label3->Caption = "Ergebnis der Division: " + String(Ergebnis);
  51. }
  52. //---------------------------------------------------------------------------
  53.